<!doctype HTML>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<p>This tests for a bug where moving the selection to the end of the document
would move it outside of an editable region if the selection started just before
a table.</p>
<div id="sample" contenteditable><table contenteditable="false" style="border: 1px solid #aaa"><tr><td>foo</td></tr></table></div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var sample = document.getElementById('sample');
    selection.collapse(sample, 0);
    selection.modify('move', 'forward', 'documentBoundary');

    var anchor = sample;
    assert_equals(selection.anchorNode, anchor, 'anchorNode');
    assert_equals(selection.anchorOffset, 1, 'anchorOffset');
    assert_equals(selection.focusNode, anchor, 'focusNode');
    assert_equals(selection.focusOffset, 1, 'focusOffset');
});
</script>
